package com.nb.hdj.testCase.teamModule;

import com.nb.hdj.testCase.consultModule.InsertConsultCase;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description: 查看团队数据正确展示测试用例
 * @Author: hedongjia
 * @Date: 2021/12/2 下午4:52
 * @Version: v1.0
 */
public class ViewTeamCase extends TeamCaseBase{
    private static final Logger logger = LoggerFactory.getLogger(TeamCaseBase.class);

    /**
     * 查看团队成员数据测试用例
     * @param driver
     * @return
     */
    public boolean viewTeam(WebDriver driver){
        try {
            //点击团队管理
            Thread.sleep(1500);
            seleniumUtil.elementClick(driver, By.xpath(teamMap.get("menuElement")));
            //查看营销管理中心
            //seleniumUtil.elementClick(driver, By.xpath(teamMap.get("marketingManagementCenterElement")));
            //控制向下滑动到浙江区域
            seleniumUtil.slideTargetPosition(driver,By.xpath(teamMap.get("zheJiangAreaElement")));
            //点击北京下拉框
            //seleniumUtil.elementClick(driver, By.xpath(teamMap.get("beiJingDownElement")));
            //点击北京区域 进入
            seleniumUtil.elementClick(driver,By.xpath(teamMap.get("beiJingElement")));
            Thread.sleep(1000);
            //获取第一页第一行员工姓名
            String bJFitstEmployees = seleniumUtil.getElementText(driver, By.xpath(teamMap.get("bJFitstEmployees")));
            //获取第一页第一行员工姓名
            String bJLastEmployees = seleniumUtil.getElementText(driver, By.xpath(teamMap.get("bJLastEmployees")));
            if(StringUtils.isNotEmpty(bJFitstEmployees)&&StringUtils.isNotEmpty(bJLastEmployees)){
                return true;
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 搜索团队数据正确展示测试用例
     * @param driver
     * @return
     */
    public boolean selectTeam(WebDriver driver){
        //控制向上滑动到领导区域
        seleniumUtil.slideTargetPosition(driver,By.xpath(teamMap.get("topLeadersAreaElement")));
        try {
            //部门搜索框输入内容
            String departmentInput="高层领导";
            seleniumUtil.elementClickAndClearAndInput(driver,By.xpath(teamMap.get("departmentSearchElement")),departmentInput);
            if(seleniumUtil.elementTextIsContains(driver,By.xpath(teamMap.get("topLeadersAreaElement")),departmentInput)){
                return true;
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return false;
    }
}
